package com.baturu.vin.benz.dal.dao;

import com.baturu.vin.benz.dto.BenzSuperDescDTO;
import com.baturu.vin.benz.dto.BenzSuperMainGroupDTO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.Collection;
import java.util.List;

/**
 * BenzMainGroupDAO
 * 主组相关查询
 *
 * @author majianming
 * @date 2019-04-19 15:19
 */
public interface BenzMainGroupDAO {

    /**
     * 查询主组信息
     *
     * @param catNos 车型
     * @return
     */
    @Results(value = {
            @Result(column = "CATNUM", property = "catNum"),
            @Result(column = "GROUPNUM", property = "groupNo"),
            @Result(column = "DESCIDX", property = "descIndex"),
    })
    @Select({"<script>",
            "select CATNUM,GROUPNUM,DESCIDX from bm_group_v ",
            " where CATNUM IN ",
            "<foreach item='catNum' collection='catNos' index='index' open='(' separator=',' close=')'>",
            "#{catNum}",
            "</foreach>",
            "</script>"})
    List<BenzSuperMainGroupDTO> queryMainGroup(@Param("catNos") Collection<String> catNos);

    /**
     * 查询主组解释
     *
     * @param descIndexs
     * @param landCode
     * @return
     */
    @Results(value = {
            @Result(column = "DESCIDX", property = "descIndex"),
            @Result(column = "TEXT", property = "desc")
    })
    @Select({"<script>",
            "select DESCIDX,TEXT from BM_DICTIONARY_V",
            " where LANG = #{landCode} AND DESCIDX IN ",
            "<foreach item='descIndex' collection='descIndexs' index='index' open='(' separator=',' close=')'>",
            "#{descIndex}",
            "</foreach>",
            "</script>"})
    List<BenzSuperDescDTO> queryMainGroupDesc(@Param("descIndexs") Collection<String> descIndexs, @Param("landCode") String landCode);
}
